cmake_minimum_required (VERSION 2.8)
project (etcd-cpp-api)

set (etcd-cpp-api_VERSION_MAJOR 0)
set (etcd-cpp-api_VERSION_MINOR 1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG  "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0 -Wall -pg -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-ggdb -O2 -Wall -std=c++11")


set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

set(LFT_YUN_LIBS $ENV{LFT_YUN_LIBS})

# include search dir
include_directories(
	/usr/include
	/usr/local/include
	${LFT_YUN_LIBS}/l-include
	${LFT_YUN_LIBS}/include
	${PROJECT_SOURCE_DIR}/
	${PROJECT_SOURCE_DIR}/src
	${PROJECT_SOURCE_DIR}/proto
	${PROJECT_SOURCE_DIR}/v3
)

# lib search dir
link_directories(
	${LFT_YUN_LIBS}/libs/linux
	${LFT_YUN_LIBS}/libs/linux/grpc
	${LIBRARY_OUTPUT_PATH}
)

##################################################################
file(GLOB_RECURSE
	LIB_FILES
	"v3/*.cpp"
	"src/*.cpp"
	"proto/*.cc"
)

add_library(etcd-cpp-api ${LIB_FILES})

##################################################################
file(GLOB_RECURSE
	TEST_FILES
	"tst/*.cpp"
)
add_executable(etcd_test ${TEST_FILES})
target_link_libraries(etcd_test
	etcd-cpp-api
	-lcpprest
	-lgrpc++
	-lgrpc
	-lares
	-lgpr
	-lprotobuf
	-lssl
	-lcrypto
	-lboost_system
	-lz
	-ldl
	-lpthread
	-lstdc++
)
